Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeBlock,ProgramAst: implement Serialize/Deserialize #1173

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

hackaugusto
Copy link
Contributor

Describe your changes

review/merge after #1172

adds serializer/deserializer to CodeBlock and ProgramAst.

Checklist before requesting a review

  • Repo forked and branch created from next according to naming convention.
  • Commit messages and codestyle follow conventions.
  • Relevant issues are linked in the PR description.
  • Tests added for new functionality.
  • Documentation/comments updated according to changes.

@hackaugusto hackaugusto requested a review from bobbinth December 4, 2023 13:22
Base automatically changed from hacka-split-ast-mod to next December 4, 2023 19:24
@bobbinth bobbinth force-pushed the hacka-codeblock-programast-serialize-deserialize branch from 8f1f058 to cb1bb9e Compare December 4, 2023 23:46
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Looks good! I left a couple of small comments inline - but there is a bigger question about the general approach.

Specifically, we used to have these implementations but we removed them some time ago because we needed to specify serialization options for ProgramAst and ModuleAst, and unfortunately, Winterfell serialization traits do not provide a way to specify such options.

So, we have a couple of things to consider:

  1. If we want to provide Serializable and Deserializable implementations, what serialization options should we use as the default? (one approach is to serialize everything, which is what the current implementation is doing).
  2. Another option could be to add write_into() and read_from() methods to the struct. These methods would have similar signatures to what is in the traits, but would also take an additional AstSerdeOptions as a parameter.
    a. With this approach we may also be able get rid of write_source_locations and load_source_locations methods as these could be just another option in AstSerdeOptions.
  3. We could also combine the above approaches - e.g., implement concrete methods and then call them from trait implementations passing default AstSerdeOptions as parameters.
  4. Lastly, we could try to modify Winterfell to add an associated type for serialization/deserialization options - but without default associated types this would be a breaking change, and may not be worth it for now.

assembly/src/ast/program.rs Outdated Show resolved Hide resolved
assembly/src/ast/program.rs Outdated Show resolved Hide resolved
assembly/src/ast/code_body.rs Outdated Show resolved Hide resolved
@hackaugusto hackaugusto requested a review from bobbinth December 5, 2023 15:13
@hackaugusto hackaugusto force-pushed the hacka-codeblock-programast-serialize-deserialize branch from cb1bb9e to 381329c Compare December 6, 2023 13:24
@bobbinth
Copy link
Contributor

bobbinth commented Dec 7, 2023

I've removed Serializable and Deserializable implementations and instead added write_into() and read_from() methods directly on ProgramAst (basically, option 2 from my previous comment). One of the reasons is that this is more consistent with how we handle serialization/deserialization of ModuleAst.

We should probably do a more comprehensive refactoring of serialization/deserialization of AST structs - but that's for a different PR.

@bobbinth bobbinth merged commit 777fae9 into next Dec 7, 2023
15 checks passed
@bobbinth bobbinth deleted the hacka-codeblock-programast-serialize-deserialize branch December 7, 2023 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants